<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>建设单位详情</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<body>
<div class="project whitebg">
    <div>
        <table id="tableList" style="height: 400px;" class="layui-hide" lay-filter="tableList"></table>
    </div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript">
    var layer;
    var form = layui.form;
    var table = null;
    var tableIns = null;
    //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
    var element = "";
    layui.use('element', function () {
        element = layui.element;
    });
    var cpName=  '${dto.cpName}';
    var modelName= '${dto.modelName}';
    var xhName=  '${dto.xhName}';
    var startDate=  '${dto.startDate}';
    var endDate=  '${dto.endDate}';
    console.log(cpName);
    console.log(modelName);
    console.log(xhName);
    console.log(startDate);
    console.log(endDate);


    layui.use('table', function () {
        table = layui.table;
        element = element;
        //方法级渲染
        tableIns = table.render({
            id: 'tableList',
            elem: '#tableList',
            url: "/search/buProjectInfo/jgfxListDetailJs?cpName=" + cpName+"&modelName="+modelName+"&xhName="+xhName+"&startDate="+startDate+"&endDate="+endDate,
            height: "auto",
            page: true,
            cols: [[
                {
                    title: '序号', width: '30%', totalRowText: '合计', templet: function (res) {
                        return res.LAY_INDEX;
                    }
                },
                {
                    field: 'unitConstruction', title: '建设单位名称', width: '70%', sort: true
                }

            ]],
            done: function (res, currentCount) {
                //***重点***：table渲染完成后渲染element进度条
                element.render();
                $(".layui-table-total .layui-table-cell").each(function (i,v) {
                    if($(i).length>0){
                        if(i==5){
                            $(v).html("100%")
                        }else{
                            var  totalvalue=$(v).html();
                            $(v).html(cutZero(totalvalue));
                        }
                    }
                });
                var  totalvalue=$(".layui-table-total .laytable-cell-1-0-4").html();
                $(".layui-table-main .laytable-cell-1-0-4").each(function (i,v) {
                    var jtvalue=$(v).html();
                    var per=((parseFloat(jtvalue)/parseFloat(totalvalue))*100).toFixed(2)+'%';
                    $(v).parents("td").next().find(".layui-table-cell").html(per);
                });



                $(".layui-table-page select").css("width", "80px");

            }
        });
       var  projectName="${project.projectName}";

    });

    //导出事件
    $('#export').on('click', function () {
        var json = {
            projectId: '${projectId}'
        }
        //使用ajax请求获取所有数据
        layerAjaxGet('/supervisor/projectManager/getTjData', json, '', function (d) {
            if (d.flag) {
                var str = "";
                var jsonarry = new Array();
                var k = 0;
                var count = 0;
                for (var y = 0; y < d.data.length; y++) {
                   var  json=d.data[y];
                    k=k+1;
                    json.ordernum=k;
                    count=count+json.count;
                    jsonarry.push(json);
                }
                jsonarry.push({"ordernum":"","fileTypeName":"合计：","count":count})
                table.exportFile('exportTable',jsonarry, 'xls');
            } else {
                layer.msg(d.msg, {icon: 2});
            }
        });
    });

</script>

</body>

</html>
